<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>咒语和药水的成功对数</title>
</head>
<body>
  <script>
    function fn(spells, potions, success) {
      let res = []
      potions.sort((a, b) => a - b)
      for (let i = 0; i < spells.length; ++i) {
        let left = 0, right = potions.length - 1
        while (left <= right) {
          let mid = (left + right) >> 1
          if (potions[mid] < success / spells[i]) left = mid + 1
          else right = mid - 1
        }
        res[i] = potions.length - left
      }
      return res
    }
    console.log(fn([5, 1, 3], [1, 2, 3, 4, 5], 7))
  </script>
</body>
</html>